Skip to content

Conversation

@Hinton
Copy link
Member

@Hinton Hinton commented Apr 25, 2025

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-13374

📔 Objective

Changes uuid to be represented as unknown which causes most as casts to fail since TS safeguards against casting "string" to unknown. Adds a new type called OrganizationId which is manually set to be equal to Tagged<Uuid, "OrganizationId"> on the TS side. This prevents mixing up the type with other Uuid's.

In order to create an OrganizationId in the application you now need to pass through unknown otherwise you get the following error message: Conversion of type 'string' to type 'Tag<"OrganizationId", never>' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.

To provide some ergonomics we should add the following function in typescript:

export function uuid<T extends Uuid>(uuid: string): T {
  if (Utils.isGuid(uuid)) {
    return uuid as T;
  }

  throw new Error(`Invalid UUID: ${uuid}`);
}

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation
    team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed
    issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

@github-actions
Copy link
Contributor

github-actions bot commented Apr 25, 2025

Logo
Checkmarx One – Scan Summary & Details2625978d-a6e3-40b1-acb3-0d7d217ed82e

Fixed Issues (1)

Great job! The following issues were fixed in this Pull Request

Severity Issue Source File / Package
MEDIUM CVE-2024-29409 Npm-@nestjs/common-10.4.6

@codecov
Copy link

codecov bot commented Apr 25, 2025

Codecov Report

Attention: Patch coverage is 95.08197% with 3 lines in your changes missing coverage. Please review.

Project coverage is 70.14%. Comparing base (1a31a1f) to head (099020f).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
crates/bitwarden-wasm-internal/src/vault/mod.rs 0.00% 2 Missing ⚠️
crates/bitwarden-uniffi/src/vault/ciphers.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #225      +/-   ##
==========================================
+ Coverage   69.93%   70.14%   +0.20%     
==========================================
  Files         214      214              
  Lines       16989    17015      +26     
==========================================
+ Hits        11882    11935      +53     
+ Misses       5107     5080      -27     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Hinton Hinton changed the title Implement bw uuid Remove duplicated Cipher and Folder client Apr 28, 2025
@Hinton Hinton requested review from coroiu and dani-garcia May 22, 2025 17:54
@Hinton Hinton requested a review from coroiu May 23, 2025 07:41
@Hinton Hinton marked this pull request as ready for review May 23, 2025 07:41
@Hinton Hinton requested a review from a team as a code owner May 23, 2025 07:41
Hinton added 2 commits May 23, 2025 09:45
…-uuid

# Conflicts:
#	crates/bitwarden-uniffi/src/vault/ciphers.rs
#	crates/bitwarden-wasm-internal/src/vault/ciphers.rs
@Hinton Hinton requested a review from coroiu May 23, 2025 09:35
@Hinton Hinton requested a review from dani-garcia May 23, 2025 11:59
@sonarqubecloud
Copy link

@Hinton Hinton merged commit 7269f31 into main May 23, 2025
43 checks passed
@Hinton Hinton deleted the arch/bw-uuid branch May 23, 2025 14:04
Hinton added a commit that referenced this pull request Aug 22, 2025
Continues the work on #225 by introducing `UserId`, `CipherId` and
`FolderId`. It also propagates the `OrganizationId` deeper into the core
crate.

- Renamed `uuid` macro to `uuid_newtype`, avoids collision with the
macro from `uuid` crate.
- Added `Hash` to the uuids.
- Added `new_v4` primarily useful in tests to generate valid UUID v4
based IDs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants